package com.supergo.config;

import org.springframework.stereotype.Component;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;

@Component
public class GoodsMap {

    private ConcurrentHashMap<String, ReentrantLock> lockMap = new ConcurrentHashMap<>();

    public ReentrantLock getLock(Long goodsId){
        return lockMap.getOrDefault(goodsId, new ReentrantLock());
    }

    public void removeLock(Long goodsId){
        lockMap.remove(goodsId);
    }

}